package com.cdn.openapi.mapper;

import com.cdn.openapi.entity.Merchant;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author cdn
 * @since 2024-08-12
 */
public interface MerchantMapper extends BaseMapper<Merchant> {
    /**
     * 判断商户是否有权限
     * @param appId
     * @return
     */
    @Select("SELECT r.api_code from merchant m\n" +
            "        INNER JOIN merchant_resource mr on m.id=mr.merchant_id\n" +
            "        INNER JOIN resource r on mr.resource_id=r.id  where m.app_id=#{appId} and m.`status`=1 and mr.`status`=1")
    Set<String> hasAuth(String appId);
}
